package image;
import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Transform;
public class RotateImage{
	
	public RotateImage(){}
	public byte[] rotateImage(byte[] imagebytes, String degrees){
		ImagesService imagesService = ImagesServiceFactory.getImagesService();
		Image oldImage = ImagesServiceFactory.makeImage(imagebytes);
		//Do rotate original image
		int degrees_int = Integer.parseInt(degrees);
		Transform rotate = ImagesServiceFactory.makeRotate(degrees_int);
		//Create new image from the result
		Image newImage = imagesService.applyTransform(rotate, oldImage);
        byte[] newImageData = newImage.getImageData();
        return newImageData;
	}
}